//导入 http 模块
const http = require('http');
const port = 3000;

//创建服务对象
const server = http.createServer((req, res) => {
  //设置响应头
  res.setHeader('content-type','text/html;charset=utf-8');
  //响应 HTML 网页
  res.end(`<!DOCTYPE html>
            <html lang="en">
            <head>
              <meta charset="UTF-8">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <title>Document</title>
              <style>
                *{
                  margin: 0;
                  padding: 0;
                }
                h2{
                  font-size: 40px;
                  color: #90c;
                }
              </style>
            </head>
            <body>
              <h2>hello, 饭已 OK 啦, 下来密西啦~~</h2>
            </body>
            </html>`);
});

//监听端口启动服务
server.listen(port, () => {
  console.log('running....');
});